package com.tarena.lbs.common.basic.converter;

import com.tarena.lbs.pojo.basic.bo.TagLibraryBO;
import com.tarena.lbs.pojo.basic.dos.TagLibraryDO;
import com.tarena.lbs.pojo.basic.param.TagLibraryParam;
import com.tarena.lbs.pojo.basic.vo.TagLibraryVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Component
public class TagLibraryConverter {

    public TagLibraryVO bo2vo(TagLibraryBO bo) {
        if (null == bo) {
            return null;
        }
        TagLibraryVO tagLibraryVO = new TagLibraryVO();
        BeanUtils.copyProperties(bo, tagLibraryVO);
        return tagLibraryVO;
    }

    public TagLibraryDO param2DO(TagLibraryParam param) {
        if (null == param) {
            return null;
        }
        TagLibraryDO tagLibraryDO = new TagLibraryDO();
        BeanUtils.copyProperties(param, tagLibraryDO);
        return tagLibraryDO;
    }

    public TagLibraryBO do2bo(TagLibraryDO tagLibraryDO) {
        if (null == tagLibraryDO) {
            return null;
        }
        TagLibraryBO tagLibraryBO = new TagLibraryBO();
        BeanUtils.copyProperties(tagLibraryDO, tagLibraryBO);
        return tagLibraryBO;
    }

    public List<TagLibraryBO> doList2boList(List<TagLibraryDO> doList) {
        List<TagLibraryBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        for (TagLibraryDO tagLibraryDO : doList) {
            TagLibraryBO tagLibraryBO = new TagLibraryBO();
            BeanUtils.copyProperties(tagLibraryDO, tagLibraryBO);
            boList.add(tagLibraryBO);
        }
        return boList;
    }


    public List<TagLibraryVO> boList2voList1(List<TagLibraryBO> doList) {
        List<TagLibraryVO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        for (TagLibraryBO tagLibraryBO : doList) {
            TagLibraryVO tagLibraryVO = new TagLibraryVO();
            BeanUtils.copyProperties(tagLibraryBO, tagLibraryVO);
            boList.add(tagLibraryVO);
        }
        return boList;
    }

}
